/**
 * Copyright (C), 2015-2018, XXX有限公司
 * FileName: MyCacheConfig
 * Author:   zhouheng
 * Date:     2018/5/22 9:39
 * Description: 自定义缓存key
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.hengby.hengcrud.config.cacheConfig;

import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.lang.reflect.Array;
import java.lang.reflect.Method;
import java.util.Arrays;

/**
 * 〈一句话功能简述〉<br> 
 * 〈自定义缓存key〉
 *
 * @author zhouheng
 * @create 2018/5/22
 * @since 1.0.0
 */
@Configuration
public class MyCacheConfig {

    @Bean(value = "myKeyGenerator")
    public KeyGenerator keyGenerator(){
        return new KeyGenerator() {
            @Override
            public Object generate(Object target, Method method, Object... params) {
                return method.getName()+"["+ Arrays.asList(params).toString()+"]";
            }
        };
    }
}